package cn.pzaily.fealetter.controller;

import cn.pzaily.crab.tools.http.enumeration.AppHttpCodeEnum;
import cn.pzaily.crab.tools.http.result.ResponseResult;
import cn.pzaily.fealetter.dto.BatchParamsDTO;
import cn.pzaily.fealetter.dto.ParamsDTO;
import cn.pzaily.fealetter.service.SendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @PackageName: cn.pzaily.fealetter.controller
 * @Description:
 * @Author: Pang
 * @Date: 2021-11-21 17:19
 */
@Api(tags = "短信发送接口")
@RestController
@RequestMapping(value = "/node")
@Slf4j
public class SendNoteController {

    private SendService sendService;

    public SendNoteController(SendService sendService){
        this.sendService = sendService;
    }

    @ApiOperation("发送短信")
    @RequestMapping(value = "/send", method = RequestMethod.POST)
    public ResponseResult send(@RequestBody ParamsDTO paramsDTO) {
        log.info("发送短信 params：{}", paramsDTO);
        sendService.send(paramsDTO);
        return ResponseResult.okResult(AppHttpCodeEnum.SEND_MESS_SUCCESS);
    }

    @ApiOperation("批量发送短信")
    @RequestMapping(value = "/batchSend", method = RequestMethod.POST)
    public ResponseResult batchSend(@RequestBody BatchParamsDTO batchParamsDTO) {
        log.info("批量发送短信 params：{}", batchParamsDTO);
        sendService.batchSend(batchParamsDTO);

        return ResponseResult.okResult(AppHttpCodeEnum.SEND_MESS_SUCCESS);
    }

}
